<?php
// 本类由系统自动生成，仅供测试用途
class JobAction extends BaseAction {
	
	public function show() {
		
		$dao = D ( 'Job' );
		
		$id = ( int ) $_GET ['id'];
		$vo = $dao->find ( $id ); //职位
		

		if ($vo ['checked'] == 0) {
			$this->error ( '职位未通过审核！' );
		}
		
		//标题
		$title = $vo ['job_name'];
		$web_title = $title . ' - ' . $this->webInfo ['web_title'];
		//关键词
		$keyword = $this->webInfo ['web_key'];
		$web_keyword = $title . ',' . $keyword;
		//描述
		$descp = $this->webInfo ['web_desc'];
		$web_desc = $title . ',' . $descp;
		
		//输出变量到模板
		$this->assign ( 'web_title', $web_title );
		$this->assign ( 'web_key', $web_keyword );
		$this->assign ( 'web_desc', $web_desc );
		$this->assign ( 'vo', $vo ); //职位		
		

		//模板		
		$tpl = C ( 'TPL_PATH' ) . $vo ['content_tpl_id'] . '.html';
		
		
		//输出模板		
		$this->display ( $tpl );
	
	}
	
	public function index() {
		
		$dao = D ( "Job" );
		
		//排序字段 默认为主键名
		if (isset ( $_REQUEST ['_order'] )) {
			$order = $_REQUEST ['_order'];
		} else {
			$order = ! empty ( $sortBy ) ? $sortBy : $dao->getPk ();
		}
		//排序方式默认按照倒序排列
		//接受 sost参数 0 表示倒序 非0都 表示正序
		if (isset ( $_REQUEST ['_sort'] )) {
			$sort = $_REQUEST ['_sort'] ? 'asc' : 'desc';
		} else {
			$sort = $asc ? 'asc' : 'desc';
		}
		
		//过滤条件
		if (isset ( $_REQUEST ['job_name'] ) && ! empty ( $_REQUEST ['job_name'] )) {
			$map ['job_name'] = array ('like', '%'.$_REQUEST ['job_name'] . '%' );
			$this->assign ( 'job_name', $_REQUEST ['job_name'] );
		}
		
		
		if (isset ( $_REQUEST ['pub_date'] ) && ! empty ( $_REQUEST ['pub_date'] )) {
			$map ['pub_date'] = $_REQUEST ['pub_date'];
			$this->assign ( 'pub_date', $map ['pub_date'] );
		}		
		
		//取得满足条件的记录数
		$count = $dao->where ( $map )
			->count ( 'id' );			
		if ($count > 0) {
			import ( "ORG.Util.Page" );
			//创建分页对象
			if (! empty ( $_REQUEST ['listRows'] )) {
				$listRows = $_REQUEST ['listRows'];
			} else {
				$listRows = '';
			}
			$p = new Page ( $count, $listRows );
			//分页查询数据
			

			$voList = $dao->where ( $map )
				->order ( "`" . $order . "` " . $sort )
				->limit ( $p->firstRow . ',' . $p->listRows )
				->findAll ();
			
			//分页跳转的时候保证查询条件
			foreach ( $map as $key => $val ) {
				if (! is_array ( $val )) {
					$p->parameter .= "$key=" . urlencode ( $val ) . "&";
				}
			}
			//分页显示
			$page = $p->show ();
			//列表排序显示
			$sortImg = $sort; //排序图标
			$sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列'; //排序提示
			$sort = $sort == 'desc' ? 1 : 0; //排序方式
			//模板赋值显示
			$this->assign ( 'list', $voList );
			$this->assign ( 'sort', $sort );
			$this->assign ( 'order', $order );
			$this->assign ( 'sortImg', $sortImg );
			$this->assign ( 'sortType', $sortAlt );
			$this->assign ( "page", $page );
		}
		
		
		
		
		$title = '职位搜索';
		$web_title = $title . ' - ' . $this->webInfo ['web_title'];
		//关键词		
		$web_keyword = $title . ',' . $this->webInfo ['web_key'];
		//描述
		$web_desc = $title . ',' . $this->webInfo ['web_desc'];
		
		//输出变量到模板
		$this->assign ( 'web_title', $web_title );
		$this->assign ( 'web_key', $web_keyword );
		$this->assign ( 'web_desc', $web_desc );
		$this->assign ( 'vo', $vo ); //分类信息
		

		//模板		
		//$tpl = C ( 'TPL_PATH' ) . $vo ['list_tpl_id'] . '.html';		
		
		//输出模板		
		$this->display ( );
	}
}
?>